//
// Created by 11510 on 2024/6/23.
//

#ifndef TEXTQUERY_NOTQUERY_H
#define TEXTQUERY_NOTQUERY_H

#include "Query.h"
#include "QueryBase.h"

class NotQuery : public QueryBase {

    friend Query operator~(const Query &);

    NotQuery(const Query &q) : query(q) {}

    std::string rep() const {
        return "~(" + query.rep() + ")";
    }

    QueryResult eval(const TextQuery &) const;

    Query query;
};


inline Query operator~(const Query &operand) {
    /* 此处隐式使用Query()的构造 */
    return shared_ptr<QueryBase>(new NotQuery(operand));
}

#endif //TEXTQUERY_NOTQUERY_H
